package com.atguigu.dao.impl;

import com.atguigu.dao.CompanyDao;
import com.atguigu.pojo.Company;
import com.atguigu.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CompanyDaoImpl implements CompanyDao {
    @Override
    public List<Company> findAllCompany() throws SQLException {
        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());

        String sql ="select id id,company_name companyName from sys_company";
        List<Company> list = qr.query(sql, new BeanListHandler<Company>(Company.class));
        return list;
    }
}
